package com.yyk.yiliao.ui.trade;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import com.yyk.yiliao.R;
import com.yyk.yiliao.base.BaseActivity;

import java.text.DecimalFormat;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 支付成功
 */
public class PayMoneySuccendActivity extends BaseActivity {


    @BindView(R.id.tv_money)
    TextView tvMoney;
    @BindView(R.id.bt_next)
    Button btNext;
    @BindView(R.id.tv_payflag) //支付方式
            TextView tvPayflag;
    private String payflag;

    @Override
    public int getLayoutId() {
        return R.layout.activity_pay_money_succend;
    }

    @Override
    public void initView() {
        initToolbar();
    }

    private void initToolbar() {
//        setBackArrow(new ToolbarListenter() {
//            @Override
//            public void onClickListenter() {
//                if (RechargeActivity.intanse != null) {
//                    RechargeActivity.intanse.finish();
//                }
//                finish();
//            }
//        });
        if (payflag != null) {
            setTitle("充值成功");
        } else {
            setTitle("支付成功");
        }

    }

    @Override
    public void initData() {
        if (getBundle() != null) {
            String money = getBundle().getString("money");
            if (getBundle().containsKey("payflag")) {
                payflag = getBundle().getString("payflag");
                tvPayflag.setText(payflag);
            }
            DecimalFormat decimalFormat = new DecimalFormat("#.##");
            String format = decimalFormat.format(Float.valueOf(money));
            tvMoney.setText("￥" + format);
        }
    }


    @OnClick(R.id.bt_next)
    public void onViewClicked() {
////        intent.setFlags方法中的参数值含义 - berber78的专栏 - CSDN博客  https://blog.csdn.net/berber78/article/details/7278408
//        Intent intent = new Intent(mActivity, MyAccountActivity.class);
////        finish();
//        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//        startActivity(intent);
        if (RechargeActivity.intanse != null) {
            RechargeActivity.intanse.finish();
        }
        finish();

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
